﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public abstract class UIItemBase : UIBase
{
    public ItemDefine mKey;
    public UILayer mLayer;
    public object[] _params;
    public RectTransform mParent;

    public void Init(ItemDefine key, GameObject go)
    {
        Init(go);
        mKey = key;
        DoLoaded();
    }

    public void Reset(RectTransform parent)
    {
        mParent = parent;
        mTran.SetParent(mParent);
        mTran.localPosition = Vector3.zero;
        mTran.localScale = Vector3.one;
    }

    public void Create(RectTransform parent, params object[] param)
    {
        mGo.SetActive(true);
        _params = param;
        Reset(parent);
        DoCreate();
    }

    public void Destory()
    {
        mGo.SetActive(false);
        _params = null;
        Clear();
        DoDestory();
    }

    public abstract void DoLoaded();
    public abstract void DoCreate();
    public abstract void DoDestory();
}
